package com.yydream.dto;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

public class Paging<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 总记录数
     */
    private long totalCount;
    /**
     * 每页记录数
     */
    private long pageSize;
    /**
     * 总页数
     */
    private long totalPage;
    /**
     * 当前页数
     */
    private long currPage;
    /**
     * 列表数据
     */
    private List<T> list;


   public Paging(){
       this.list = Collections.emptyList();
       this.totalCount = 0l;
       this.pageSize=10l;
       this.currPage = 1l;
   }

   public Paging(long totalCount,long pageSize){
       this(totalCount,pageSize,0);
   }

    public Paging(long totalCount,long pageSize,long currPage){
        this.list = Collections.emptyList();
        this.totalCount = totalCount;
        this.pageSize=pageSize;
        this.currPage = currPage;
        this.totalPage = (long) Math.ceil((double) totalCount / pageSize);
    }


    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public long getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public long getCurrPage() {
        return currPage;
    }

    public void setCurrPage(int currPage) {
        this.currPage = currPage;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
